﻿using NSBus.Dto.Commands;
using NServiceBus;
using Sanelib.Services;

namespace NSBus.Server.CommandHandlers
{
    public class SendMailHandler : IHandleMessages<SendEmailCommand>
    {
        private readonly IEmailSender _emailSender;

        public SendMailHandler(IEmailSender emailSender)
        {
            _emailSender = emailSender;
        }

        public void Handle(SendEmailCommand message)
        {
            _emailSender.SendTextEmail(message.Subject, message.MessageBody, message.To);
        }
    }
}
